/*
Realistic Unit Modification v4.0 Dialog 
v4.0.0.1 [ALPHA]
Concept & Development by Draper & Raps | [VRC]
*/

private ["_helo","_spwn","_callsign","_pilot","_gunner","_grp","_mkrname","_mkrname2","_wpAH"];

/* define variables */
_helo = _this select (count _this - 1);
_spwn = _this select 3;
_callsign = _this select 1;

/* define pilot, gunner, and group/side */
_pilot = driver _helo;
_gunner = gunner _helo;
_grp = group _pilot;

/* define markers and remove them from map */
_mkrname = format ["%1station",_helo];
_mkrname2 = format ["%1station2",_helo];
deletemarkerLocal _mkrname;
deletemarkerLocal _mkrname2;

/* dialog from pilot to player */
["RTB",[player,_pilot,_callsign]] execVM (RUM_PATH+"AHel\radiodialogs.sqf");
sleep 5;

/* waypoints created to RTB */
_wpAH=_grp addWaypoint [getpos _spwn, 0];
_wpAH setWaypointType "MOVE";
_wpAH setWaypointSpeed "LIMITED";
_wpAH setWaypointBehaviour "CARELESS";
_wpAH setWaypointCombatMode "BLUE";
_wpAH setWaypointCompletionRadius 50;
_helo flyInheight 32;

sleep 4.75;
deleteWaypoint [_grp, 0];

_wpAH=_grp addWaypoint [getpos _spwn, 0];
_wpAH setWaypointType "MOVE";
_wpAH setWaypointSpeed "NORMAL";
_wpAH setWaypointBehaviour "CARELESS";
_wpAH setWaypointCombatMode "BLUE";
_wpAH setWaypointCompletionRadius 200;
_grp setcurrentWaypoint _wpAH;
_helo flyInheight RUM_AHEL_flyHeight;

/* waits till waypoints are complete */
waitUntil{(!alive _helo) || (moveToCompleted _pilot)};

/* delte pilot, gunner, and helo that were spawned initially */
deleteVehicle _pilot;
deleteVehicle _gunner;
deleteVehicle _helo;

/* defined in RUM settings, waits to makle the helo available */
sleep RUM_AHel_ReSupTime;

/* makes the helo available in the PDA for all players */
RUM_AHelAircraft_Spawn = RUM_AHelAircraft_Spawn + [_this];
publicVariable "RUM_AHelAircraft_Spawn";

/* exits script */
if(true)exitwith{};
